﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Beyondbit.Desktop.Common;
using RBS.Common;
using RBS.Common.DEncrypt;
using RBS.Common.JsonEntity;
using RBS.Core.Model.Hotel;
using Webdiyer.WebControls.Mvc;

namespace RBS.Web.Hotel.Controllers
{
    public class HotelController : BaseController
    {
        public RBS.Core.BLL.Hotel.H_Hotels Bll = new RBS.Core.BLL.Hotel.H_Hotels();
        // GET: /Hotel/
        #region 酒店基本信息管理  
        public ActionResult HotelEdit()
        {
            var msg = Request["msg"]   ; 
            var model = new RBS.Core.Model.Hotel.H_Hotels();
            if (CurrentUser.HotelId != 0)
            {
                model = Bll.GetModelByCache(CurrentUser.HotelId);
            }
            if (CurrentUser.HotelId == 0)
            {
                msg = "请先填写酒店信息才能进行下一步操作！";
            }
            ViewBag.msg = msg;
            return View(model);
        }
        /*[Authorize(Roles = "admins")]  */
        [HttpPost]
         public ActionResult HotelEdit(FormCollection collection)
        {
            var oldmodel = Bll.GetModelByCache(CurrentUser.HotelId);  
            oldmodel.Cutlery = collection["Cutlery"];
            oldmodel.Feature = collection["Feature"];
            oldmodel. Promotional = collection["Promotional"];
            oldmodel.H_Name = collection["H_Name"];
            oldmodel.Address = collection["Address"];
            oldmodel.Telphone = collection["Telphone"];
            oldmodel.Mobile = collection["Mobile"];
            oldmodel.Cuisine = collection["Cuisine"];
            oldmodel.Location = collection["Location"];
            oldmodel.Parking = collection["Parking"];
            oldmodel.WIFI = collection["WIFI"];
            oldmodel.License = collection["License"];  
            oldmodel.AuditStatus = Convert.ToInt32(collection["AuditStatus"]);

            oldmodel.Province = collection["Province"];
            oldmodel.City = collection["City"];
            oldmodel.Region = collection["Region"];
            oldmodel.ShopBegintime = collection["ShopBegintime"];
            oldmodel.ShopEndtime = collection["ShopEndtime"];

            var hotelMapBll = new RBS.Core.BLL.H_HotelMap();
             
            var mapid = "";
            if (hotelMapBll.ExistsHotelId(oldmodel.H_id))
            {
                mapid = hotelMapBll.GetModelByHotelId(oldmodel.H_id).MapId;
            } 
            var mapInfo = hotelMapBll.AMapAdd(mapid, oldmodel); 
            var map = new RBS.Core.Model.H_HotelMap
            {
                HotelId = oldmodel.H_id,
                MapId = mapInfo._id,
                lng = oldmodel.Location.Split(',')[0],
                lat = oldmodel.Location.Split(',')[1]
            };
            hotelMapBll.Save(map);


            if (Bll.Update(oldmodel)) { 
                return RedirectToAction("HotelEdit", new { msg = "保存成功！" });
            } 
            return View();
        }
         
         
         public ActionResult HotelSetting()
         {
             ViewBag.msg = Request["msg"];
             var bll = new RBS.Core.BLL.Hotel.H_Hotel_Setting();
             var model = bll.GetModelByHotelId(CurrentUser.HotelId) ??
                          new RBS.Core.Model.Hotel.H_Hotel_Setting { HotelId = CurrentUser.HotelId }; 
             return View(model);
        }
        [HttpPost]
         public ActionResult HotelSetting(FormCollection collection)
        {  
            var model = new  RBS.Core.Model.Hotel.H_Hotel_Setting
                {
                    HotelId = int.Parse(collection["HotelId"]),
                    RetentionTime =   int.Parse(collection["RetentionTime"]),
                    PriorityModel =  collection["PriorityModel"],
                    TimeoutWarning =   int.Parse(collection["TimeoutWarning"]) 
                };  
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Setting();
            if (collection["Id"] != "0")
            {
                model.Id = Convert.ToInt32(collection["Id"]);
                bll.Update(model); 
            }
            else
            { 
                bll.Add(model); 
            }
            return RedirectToAction("HotelSetting",new{msg="保存成功"});
        }


        #endregion

        #region 酒店用户管理
        /// <summary>
        /// 酒店用户列表
        /// </summary>  
        /// <returns></returns>
        public ActionResult HotelUserList(string kword=null)
        {
            string where = string.Empty;
            if (kword != null)
            {
                where = " and( H_UID like '%" + kword + "%' or H_UserName like '%" + kword + "%')";
            }
            List<RBS.Core.Model.Hotel.H_Hotel_Users> hotelUserses = new RBS.Core.BLL.Hotel.H_Hotel_Users().GetModelList(" HotelId=" + CurrentUser.HotelId + where);
            ViewData.Model = hotelUserses;
            ViewBag.defaultpassword = RBSKeys.Defaultpassword;
            ViewBag.HotelId = CurrentUser.HotelId;
            return View();
        }
        /// <summary>
        /// 酒店用户编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult HotelUserEdit(int id = 0 )
        {
            var model = new RBS.Core.Model.Hotel.H_Hotel_Users {HotelId = CurrentUser.HotelId, regTime = DateTime.Now};
            string[] role = null;
            if (id != 0)
            { 
                var bll = new RBS.Core.BLL.Hotel.H_Hotel_Users();
                model = bll.GetModel(id);
                ViewBag.defaultpassword = RBSKeys.Defaultpassword;
                role = model.RoleIds.Split(',');
            }
            ViewBag.roles = role;
            ViewData.Model = model;
            return View();
        } 
        [HttpPost]
        public ActionResult HotelUserEdit(int id,FormCollection collection)
        {
            var model = GetHotelUserModel(collection); 
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Users();
            if (collection["Id"] != "0")
            {
                
                model.Id = Convert.ToInt32(collection["Id"]);
                bll.Update(model); 
            }
            else
            { 
                bll.Add(model); 
            }

           
            return   RedirectToAction("HotelUserList", "Hotel");
        }
        public RBS.Core.Model.Hotel.H_Hotel_Users GetHotelUserModel(FormCollection collection)
        {

    
            var model = new RBS.Core.Model.Hotel.H_Hotel_Users()
            {
                HotelId = CurrentUser.HotelId,
                H_UID = collection["H_UID"],
                H_UserName = collection["H_UserName"], 
                RoleIds = collection["RoleIds"],
                regTime = Convert.ToDateTime(collection["regTime"]),
                DeptId = collection["DeptId"]
            };
            model.Password = collection["PasswordNew"] != RBSKeys.Defaultpassword ? DESEncrypt.Encrypt(collection["PasswordNew"]) : collection["Password"];
           
            return model;
        }

 
       [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult DeleteUser(string ids, string returnUrl)
        {
            var ret = new JsonReturnMessages(); 
            try
            {
                foreach (var id in ids.TrimEnd(',').Split(',').ToList())
                {
                    new RBS.Core.BLL.Hotel.H_Hotel_Users().Delete(int.Parse(id));
                }
            }
            catch (Exception exception)
            {
                ret.IsSuccess = false;
                ret.Msg = "操作失败！";
                return Json(ret);
            } 
            ret.IsSuccess = true;
            ret.Msg = "操作成功";
            ret.Data = !string.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("HotelUserList", "Hotel");
            return Json(ret);
        }

        #region 用户锁定 
            public ActionResult UserAudit(int id,int status)
            {
                new RBS.Core.BLL.Hotel.H_Hotel_Users().UpdateStatus(id,status);
                return RedirectToAction("HotelUserList");
            } 
            #endregion 
       #endregion

        #region 酒店保证金管理

        public string GetRecognizanceCount(int hotelId)
        {
           string  m=  new RBS.Core.BLL.Hotel.H_Hotel_Recognizance().GetRecognizanceCount(hotelId);
            return string.Format("余额：{0} 元", m);
        }

        public ActionResult HotelRecognizance(int ids = 0, int id = 1, string kword = null)
        {

            ViewBag.m = GetRecognizanceCount(CurrentUser.HotelId);
            const int pageSize = 10; 
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Recognizance();
            // var admin = GetAdminInfo(); //取得当前管理员信息
            if (kword != null) kword = kword.Replace("'", "");
            var strTemp = new StringBuilder();
            if (!string.IsNullOrEmpty(kword))
            {
                strTemp.Append(" and  HotelId in ( select H_id from H_Hotels where H_Name   like  '%" + kword + "%')");
            }
            string strWhere = " and HotelId="+CurrentUser.HotelId+ strTemp.ToString();
            const string orderby = " id  desc";
            var startIndex = id;

            int totalItems = 0; //要分页的总记录数
            DataTable dt = bll.GetList(pageSize, startIndex, strWhere, orderby, out totalItems).Tables[0];
            //PagedList构造函数 
            var list = IListDataSet.DataTableToIList<RBS.Core.Model.Hotel.H_Hotel_Recognizance>(dt);
            PagedList<RBS.Core.Model.Hotel.H_Hotel_Recognizance> arts = null;
            if (list != null)
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Recognizance>(list, id, pageSize, totalItems);
            else
            {
                list = new List<RBS.Core.Model.Hotel.H_Hotel_Recognizance>();
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Recognizance>(list, id, pageSize, totalItems);
            }
            return View(arts);
        }
        #endregion

        #region 酒店座位信息管理 HotelSeat
         
        //list
        public ActionResult HotelSeat(int id = 1, string kword = null, string Category=null)
        {
            const int pageSize = 10; 
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Seat();
            // var admin = GetAdminInfo(); //取得当前管理员信息
            if (kword != null) kword = kword.Replace("'", "");
            var strTemp = new StringBuilder();
            if (!string.IsNullOrEmpty(kword))
            {
                strTemp.Append(" and (H_UID like  '%" + kword + "%' or H_UserName like '%" + kword + "%')");
            }
            if (!string.IsNullOrEmpty(Category))
            {
                strTemp.Append(" and Category='" + Category + "'");
            }
            string strWhere = " and HotelId =" +CurrentUser.HotelId+ strTemp.ToString();
            const string orderby = " id  desc";
            var startIndex = id;

            int totalItems = 0; //要分页的总记录数
            DataTable dt = bll.GetList(pageSize, startIndex, strWhere, orderby, out totalItems).Tables[0];
            //PagedList构造函数 
            var list = IListDataSet.DataTableToIList<RBS.Core.Model.Hotel.H_Hotel_Seat>(dt);
            PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat> arts = null;
            if (list != null)
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat>(list, id, pageSize, totalItems);
            else
            {
                list = new List<RBS.Core.Model.Hotel.H_Hotel_Seat>();
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat>(list, id, pageSize, totalItems);
            }
            return View(arts);
        }
        public ActionResult SeatView(int id = 1, string kword = null)
        {
            const int pageSize = 10; 
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Seat();
            // var admin = GetAdminInfo(); //取得当前管理员信息
            if (kword != null) kword = kword.Replace("'", "");
            var strTemp = new StringBuilder();
            if (!string.IsNullOrEmpty(kword))
            {
                //strTemp.Append(" and (H_UID like  '%" + kword + "%' or H_UserName like '%" + kword + "%')");
            }
            string strWhere = " and HotelId =" +CurrentUser.HotelId+ strTemp.ToString();
            const string orderby = " id  desc";
            var startIndex = id;

            int totalItems = 0; //要分页的总记录数
            DataTable dt = bll.GetList(pageSize, startIndex, strWhere, orderby, out totalItems).Tables[0];
            //PagedList构造函数 
            var list = IListDataSet.DataTableToIList<RBS.Core.Model.Hotel.H_Hotel_Seat>(dt);
            PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat> arts = null;
            if (list != null)
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat>(list, id, pageSize, totalItems);
            else
            {
                list = new List<RBS.Core.Model.Hotel.H_Hotel_Seat>();
                arts = new PagedList<RBS.Core.Model.Hotel.H_Hotel_Seat>(list, id, pageSize, totalItems);
            }
            return View(arts);
        }

      
        //edit
        public ActionResult HotelSeatEdit(int id = 0)
        {
            var model = new RBS.Core.Model.Hotel.H_Hotel_Seat();
            model.HotelId = CurrentUser.HotelId;
            if (id != 0)
            { 
                var bll = new RBS.Core.BLL.Hotel.H_Hotel_Seat();
                model = bll.GetModel(id);
            }
            ViewData.Model = model;
            return View();
        }
        [HttpPost]
        public ActionResult HotelSeatEdit(FormCollection collection)
        {
           /* string outpath = "UploadImages" + "\\" + "Hotels\\" + CurrentUser.HotelId + "\\Seat\\";
            string physicalPath = HttpContext.Server.MapPath("~/") + outpath;
            if (!Directory.Exists(physicalPath))
            {
                Directory.CreateDirectory(physicalPath);
            }
            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var httpPostedFileBase = Request.Files[0];
                    if (httpPostedFileBase != null)
                    {
                        var postedFileBase = Request.Files[i];
                        if (postedFileBase != null)
                        {
                            string filename = System.IO.Path.GetFileName(postedFileBase.FileName);
                            httpPostedFileBase.SaveAs(physicalPath + filename);
                            outpath += filename;
                        }
                        else
                        {
                            outpath = collection["Picture"];
                        } 
                    }
                }
            }
            catch
            {
                outpath = "";
            }*/ 
            var model = new RBS.Core.Model.Hotel.H_Hotel_Seat
            {
                HotelId = Convert.ToInt32(collection["HotelId"]),
                Floor =  collection["Floor"],
                Category =  collection["Category"],
                Hall =  collection["Hall"],
                RoomNumber =  collection["RoomNumber"],
                Name = collection["Name"],
                Numbers =   Convert.ToInt32(collection["Numbers"]),
                Picture = collection["Picture"],
                AOBT =   Convert.ToInt32(collection["AOBT"]),
            }; 
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Seat();
            if (collection["Id"] != "0")
            {
                model.Id = Convert.ToInt32(collection["Id"]);
                bll.Update(model);
               // AddAdminLog(RBSEnums.ActionEnum.Edit.ToString(), "修改:" + model.Id); //记录日志
            }
            else
            {

                bll.Add(model);
              //  AddAdminLog(RBSEnums.ActionEnum.Add.ToString(), "添加:" + model.Id); //记录日志
            }
            return RedirectToAction("HotelSeat");
        }


        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult HotelSeatDelete(string ids, string returnUrl)
        {
            var ret = new JsonReturnMessages();
           // ChkAdminLevel("#", RBSEnums.ActionEnum.Delete.ToString()); //检查权限  后期考虑要删除图片 或者做个文件管理器
            try
            {
                foreach (var id in ids.TrimEnd(',').Split(',').ToList())
                {
                    new RBS.Core.BLL.Hotel.H_Hotel_Seat().Delete(int.Parse(id));
                }
            }
            catch (Exception exception)
            {
                ret.IsSuccess = false;
                ret.Msg = "操作失败！";
                return Json(ret);
            }
         //   AddAdminLog(RBSEnums.ActionEnum.Delete.ToString(), "删除"); //记录日志
            ret.IsSuccess = true;
            ret.Msg = "操作成功";
            ret.Data = !string.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("HotelSeat", "Hotel");
            return Json(ret);
        }


        [HttpPost]
        public JsonResult IsSeatReg(string param, string type)
        { 
            DataTable dt = null;
            if (type == "RoomNumber")
            {
                dt = new RBS.Core.BLL.Hotel.H_Hotel_Seat().GetList(" HotelId=" + CurrentUser.HotelId + "and RoomNumber='" + param + "'").Tables[0];
            }
            else if (type == "Name")
            {
                dt = new RBS.Core.BLL.Hotel.H_Hotel_Seat().GetList(" HotelId=" + CurrentUser.HotelId + "and Name='" + param + "'").Tables[0];
            } 
            var model = new CheckModel();
            if (dt != null && dt.Rows.Count> 0)
            {
                model.info = "验证不通过，数据已存在";
                model.status = "n";
            }
            else
            {
                model.info = "验证通过";
                model.status = "y";
            }
            return Json(model);
        }
         
        #region 图片上传

        /// <summary>
        /// 座位上传
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult UploadSeatImg()
        {
            var ret = new JsonImgMsg();
            string outpath = "UploadImages" + "\\" + "Hotels\\" + CurrentUser.HotelId + "\\Seat\\";
            string physicalPath = HttpContext.Server.MapPath("~/") + outpath;
            if (!Directory.Exists(physicalPath))
                Directory.CreateDirectory(physicalPath);

            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var httpPostedFileBase = Request.Files[0];
                    if (httpPostedFileBase != null)
                    {
                        var postedFileBase = Request.Files[i];
                        if (postedFileBase != null)
                        { 
                            string filename = DateTime.Now.ToString("yyyyMMddhhmmss") +
                                              System.IO.Path.GetExtension(postedFileBase.FileName);
                            httpPostedFileBase.SaveAs(physicalPath + filename); 
                            ret.name = filename;
                            ret.thumb = physicalPath;
                            ret.path = outpath + filename;
                            ret.size = postedFileBase.ContentLength;
                            ret.ext = System.IO.Path.GetExtension(postedFileBase.FileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ret.status = 0;
                ret.msg = "上传过程中发生意外错误！";
                return Json(ret);
            }
            ret.status = 1;
            ret.msg = "上传文件成功！"; 
            return Json(ret);
        }

        #endregion
        #endregion
        #region 酒店菜谱信息管理
        //public ActionResult  
        #endregion




        #region 酒店图片管理

        public ActionResult HotelImg()
        {
            var model = new RBS.Core.BLL.Hotel.H_Hotel_Img().GetModelList(" HotelId = " + CurrentUser.HotelId);
            return View(model);
        }
        [HttpPost]
        public JsonResult UploadImg()
        {
            var ret=new JsonImgMsg();
            var bll = new RBS.Core.BLL.Hotel.H_Hotel_Img();
            string outpath = "UploadImages" + "\\" + "Hotels\\"+CurrentUser.HotelId+"\\img\\";
            string physicalPath = HttpContext.Server.MapPath("~/") + outpath;
            if (!Directory.Exists(physicalPath))
                Directory.CreateDirectory(physicalPath); 

            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var httpPostedFileBase = Request.Files[0];
                    if (httpPostedFileBase != null)
                    {
                        var postedFileBase = Request.Files[i];
                        if (postedFileBase != null)
                        {
                            string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + System.IO.Path.GetFileName(postedFileBase.FileName);
                            httpPostedFileBase.SaveAs(physicalPath + filename);

                            ret.name = filename;
                            ret.path = physicalPath;
                            ret.thumb = "../"+outpath +filename;
                            ret.size = postedFileBase.ContentLength;
                            ret.ext = postedFileBase.FileName.Substring(postedFileBase.FileName.LastIndexOf('.')+1);

                              outpath += filename;
                                var model = new H_Hotel_Img
                                    {
                                        HotelId = CurrentUser.HotelId,
                                        ImgSrc = outpath,
                                        Sequence = 0
                                    };
                                bll.Add(model);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ret.status = 0;
                ret.msg = "上传过程中发生意外错误！";
                return Json(ret);
            }


           /* string msg = "{\"status\": 1, \"msg\": \"上传文件成功！\", \"name\": \""
                         + outpath + "\", \"path\": \"" + physicalPath + "\", \"thumb\": \""
                         + outpath + "\", \"size\": " + 1024 + ", \"ext\": \"" + 2014 + "\"}";*/

            ret.status = 1;
            ret.msg = "上传文件成功！";
           
            return Json(ret);
          
        }

        /// <summary>
        /// 营业执照上传
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult UploadLicense()
        {
            string outpath = "UploadImages" + "\\" + "License\\";
            string physicalPath = HttpContext.Server.MapPath("~/") + outpath;
            if (!Directory.Exists(physicalPath))
            {
                Directory.CreateDirectory(physicalPath);
            }
            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var httpPostedFileBase = Request.Files[0];
                    if (httpPostedFileBase != null)
                    {
                        var postedFileBase = Request.Files[i];
                        if (postedFileBase != null)
                        {
                            string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + System.IO.Path.GetFileName(postedFileBase.FileName);
                            httpPostedFileBase.SaveAs(physicalPath + filename);
                            outpath += filename;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                outpath = "";
            }
            return Content(outpath);
        }


        /// <summary>
        /// 酒店图片删除
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="returnUrl"></param>
        /// <returns></returns>
        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult HotelImgDelete(string ids, string returnUrl)
        {
            var ret = new JsonReturnMessages(); 
            try
            {
                foreach (var id in ids.TrimEnd(',').Split(',').ToList())
                {
                    //先删除本地文件 
                    try
                    {
                        var model = new RBS.Core.BLL.Hotel.H_Hotel_Img().GetModelByCache(int.Parse(id));
                        string delFile = HttpContext.Server.MapPath("~/") + model.ImgSrc;
                        System.IO.File.Delete(delFile);
                    }
                    catch 
                    {
                    } 
                    new RBS.Core.BLL.Hotel.H_Hotel_Img().Delete(int.Parse(id)); 
                }
            }
            catch (Exception exception)
            {
                ret.IsSuccess = false;
                ret.Msg = "操作失败！";
                return Json(ret);
            }
              ret.IsSuccess = true;
            ret.Msg = "操作成功";
            ret.Data = !string.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("HotelImg");
            return Json(ret);
        } 
        /// <summary>
        /// 酒店营业执照删除
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="returnUrl"></param>
        /// <returns></returns>
        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult HotelLicenseDelete(string ids, string returnUrl)
        {
            var ret = new JsonReturnMessages(); 
            try
            {
                foreach (var id in ids.TrimEnd(',').Split(',').ToList())
                {
                    var model = new RBS.Core.BLL.Hotel.H_Hotels().GetModelByCache(int.Parse(id));
                    //先删除本地文件 
                    try
                    { 
                        string delFile = HttpContext.Server.MapPath("~/") + model.License;
                        System.IO.File.Delete(delFile);
                    }
                    catch  
                    {
                    }
                    model.License = "";
                    new RBS.Core.BLL.Hotel.H_Hotels().Update(model);
                }
            }
            catch (Exception exception)
            {
                ret.IsSuccess = false;
                ret.Msg = "操作失败！";
                return Json(ret);
            }
              ret.IsSuccess = true;
            ret.Msg = "操作成功";
            ret.Data = !string.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("HotelEdit");
            return Json(ret);
        }


        #region 设置焦点图片 
        public JsonResult Cover(int id, int hotelid)
        { 
            var ret = new JsonReturnMessages {IsSuccess = true};
            try
            {
                ret.IsSuccess = new RBS.Core.BLL.Hotel.H_Hotel_Img().SetCover(id, hotelid);
            }
            catch(Exception exception)
            {
                ret.IsSuccess = false;
                ret.Msg = exception.Message;
            }  
            return Json(ret, JsonRequestBehavior.AllowGet); 
        }

        #endregion


        #endregion
    }

   
}
